"""
列表页
"""
from selenium.webdriver.common.by import By

from page_objects.base_page import BasePage
from utils.log_util import logger


class CategoryListPage(BasePage):

    __BTN_ADD = (By.XPATH, '//*[@id="app"]/div/div[2]/section/div/div[1]/button[2]')
    __MSG_ADD_OPERATE = (By.XPATH, '//*[@id="app"]/div/div[2]/section/div/div[2]/div[3]/table/tbody/tr[1]/td[3]/div')
    __MENU_MALL_MANAGE = (By.XPATH, '//*[@id="app"]/div/div[1]/div[1]/div/ul/div[3]/li/div')
    def click_add(self):
        logger.info("类目列表页面：点击添加")
        # self.driver.find_element(By.XPATH, "//*[text()='添加']").click()
        self.do_find(self.__BTN_ADD).click()

        from page_objects.category_create_page import CategoryCreatePage
        return CategoryCreatePage(self.driver)

    def get_operate_result(self):
        self.do_find(self.__MENU_MALL_MANAGE).click()
        # 获取冒泡消息文本
        element = self.wait_element_until_visible(self.__MSG_ADD_OPERATE)

        msg = element.text
        return msg
